-- @owner: opentestcase009
-- @date: 2023/1/3
-- @testpoint: connect by子句,省略start with


--step1:创建普通表，插入数据;expect:建表成功，插入数据成功
drop table if exists t_connectby_011 cascade;
create table t_connectby_011(name varchar, id int, fatherid int);
insert into t_connectby_011 values('A', 1, 0), ('B', 2, 1),('C',3,1),('D',4,1),('E',5,2);

--step2:省略start with关键字，查询所有行作为初始集合的递归查询;expect:成功
select * from t_connectby_011 connect by nocycle prior id = fatherid limit 10;

--step3:结合层次递归查询函数查看递归层级;expect:成功
select sys_connect_by_path(name,'-') as path, *, level from t_connectby_011 connect by nocycle prior id = fatherid limit 10;

--step4:清理环境;expect:成功
drop table t_connectby_011 cascade;
